package com.inboyu.application.service;

import com.inboyu.application.CustomerApplicationService;
import com.inboyu.application.request.CustomerCommand;
import com.inboyu.application.request.CustomerQuery;
import com.inboyu.application.response.CustomerResponse;
import com.inboyu.operation.domain.CustomerDomainService;
import com.inboyu.operation.domain.Customer;

import java.util.List;

public class CustomerAppServiceImpl implements CustomerApplicationService {

    private CustomerDomainService customerDomainService;

    public CustomerAppServiceImpl(final CustomerDomainService customerDomainService) {
        this.customerDomainService = customerDomainService;
    }

    @Override
    public void saveCustomer(CustomerCommand customerCommand) {
        Customer customer = CustomerCommand.toLeaseEntity(customerCommand);
        customerDomainService.saveCustomer(customer);
    }

    @Override
    public List<CustomerResponse> findCustomerByCondition(CustomerQuery request) {
        List<Customer> customerList = customerDomainService.findCustomerByCondition(request.operationCompanyId(), request.name(), request.mobile());
        return CustomerResponse.toCustomerResponseList(customerList);
    }
}
